{extend name="base"/}
{block name="content"}
<div id="header-frame">
    {include file="public:top" /}
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery-2.0.3.min.js'></script>
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery.form.js'></script>
    <link href="__STATIC__/admin/uploadajax/css/style.css" type="text/css" rel="stylesheet"/>
    <link href="__STATIC__/admin/css/order_index.css" type="text/css" rel="stylesheet"/>
</div>
<div id="frame-body">
    <div id="menu-frame" style="width: 100%;float: left;">
        {include file="public:menu" /}


    </div>
    <div id="main-frame" style="float: left;">
        <div id="dcMain" style="margin-left: 20px;width: 1682px;">
            <div id="urHere">DouPHP 管理中心<b>></b><strong>{$PageTitle}</strong> </div>   <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
            <h3>{$PageTitle}</h3>
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <th  align="center">订单Id</th>
                    <th  align="center">订单编号</th>
                    <th  align="center">商品信息</th>
                    <th  align="center">物流单号</th>
                    <th  align="center" class="fixedth">物流信息</th>
                    <th  align="center">总金额</th>
                    <th  align="center">商品数量</th>
                    <th  align="center">收货地址</th>
                    <th  align="center">是否付款</th>
                    <th  align="center">提醒用户支付订单</th>
                    <th  align="center">创建时间</th>
                </tr>
                {foreach name="allData" item="vo"}
                <tr>
                    <td align="center" class="fixedtd1">{$vo['order_id']}</td>
                    <td align="center">{$vo['order_number']}</td>
                    <td align="left" class="fixedtd7">
                        {foreach name="vo.arr_snap_items" item="pro"}
                        <span><input _id="{$pro['id']}-{$pro['speci_id']}" type="checkbox" class="checkboxes" name="events"/><i>产品名称：{$pro['name']}</i></span>
                        <span class="fixedtd7Span">产品规格：{foreach name="pro.speci_snap" item="vro" key="k"}  {$k}:{$vro}  {/foreach}</span>
                        <span class="fixedtd7Span">产品图片：<img src="{$pro['main_img_url']}"/></span>
                        <span class="fixedtd7Span">产品数量：{$pro['count']}</span>
                        <span class="fixedtd7Span">产品单价：{$pro['price']}</span>
                        <hr/>
                        {/foreach}
                        <input type="checkbox" id="checkall" class="checkboxe" onclick="select_all(this)"/>全选<hr/>
                    </td>
                    <td align="center" onclick="" class="buttonOn">
                        <div class="logistics_number">
                        {if condition="$vo['logistics_number']!=NULL"}
                        {$vo['logistics_number']}
                        {else/}
                        <a  onclick="showLogisticsNumberBox(this,{$vo['order_id']})">上传物流单号{/if}</a>
                        <div class="logistics_number_box">
                            <input type="text"  name="logistics_number" class="logistics_number_val" value="" />
                            <a  onclick="hideLogisticsNumberBox(this)">确定</a>
                            <a  onclick="hideLogisticsNumberBox(this)">取消</a>
                        </div>
                        </div>
                    </td>
                    <td align="left">
                        {if condition="$vo['logistics_json']!=NULL"}
                        
            <div>状态：{if condition="$vo['arr_logistics_json']['result']['deliverystatus']==1"}
                                    在途中
                                  {elseif condition="$vo['arr_logistics_json']['result']['deliverystatus']==2"/}
                                    派送中
                                  {elseif condition="$vo['arr_logistics_json']['result']['deliverystatus']==3"/}
                                    已签收
                                  {elseif condition="$vo['arr_logistics_json']['result']['deliverystatus']==4"/}
                                   派送失败
                                  {elseif condition="$vo['logistics_state']==1"/}
                                    已发货
                                   {/if}</div>
                        <div> 物流信息：</div>
                            {foreach name="vo['arr_logistics_json']['result']['list']" item="wuliu"}
                                    <div class="logistics">
                                    	<span>{$wuliu['time']}</span>
                                    	<span>{$wuliu['status']}</span>
                                    </div>
                            {/foreach}
                       {if condition="$vo['compang']"}
                      <div>物流公司：  {$vo['compang']['name']}快递 </div>
                        <div>客服电话：  {$vo['compang']['number']}</div>
                        {/if}
                        <div>发货信息：  {$vo['place']['place_addr']} {$vo['place']['addr_detail']}{$vo['place']['place_name']}{$vo['place']['mobile']} {$vo['place']['code']}</div>
                        {else/}
                        	<div class="accessToLogistics">
                        		<a href="">获取物流信息</a>
                        	</div>
                        {/if} </td>
                    <td align="center"  class="fixedtd2">{$vo['total_price']} :元</td>
                    <td align="center"  class="fixedtd3">{$vo['total_count']}:件</td>
                    <td align="left">
                      <!--  收货人姓名： <br/>{$vo.arr_snap_address['uaddres_name']} <br/>电话：<br/>{$vo.arr_snap_address['uaddres_mobile']}<br/>
                        收货地址：<br/>{$vo.arr_snap_address['uaddres_province']}/{$vo.arr_snap_address['uaddres_city']}/{$vo.arr_snap_address['uaddres_county']}<br/> 具体地址：<br/>{$vo.arr_snap_address['uaddres_detail']}-->
                    </td>
                    <td align="center" class="fixedtd4">{$vo['order_states']}</td>

                    <td align="center" class="buttonOn fixedtd5" ><a href="#" onclick="phoneYan({$vo['order_id']})">提醒用户去付款</a> <br/> <a>推荐商品</a></td>
                    <td align="center" class="fixedtd6">{$vo['createtime']|date="Y-m-d H:i",###}</td>
                </tr>
                {/foreach}
                <input type="hidden" id="arr_prodcuts" name="arr_prodcuts" value=""/>
                <input type="hidden" id="order_id" name="order_id" value=""/>
            </table>
        </div>
        </div>
        <div class="clear"></div>
        <script type="text/javascript">
            //删除分类
            function protypes_dele(message, id) {
                layer.open({
                    content : message,

                    icon:3,
                    btn : ['是','否'],
                    yes : function(){
                        var url="{:url('admin/protype/protype_dele')}";
                        var success_url="{:url('admin/protype/protypes_index')}";
                        $.post(url,{'protype_id':id},function(result){
                            if(result.status=='4')
                            {
                                dialog.success(result.message,success_url);
                            }else
                            {
                                dialog.error(result.message);
                            }
                        })
                    }
                });
            }
            //提醒用户去付款
             function phoneYan(id)
            {
                var url="{:url('admin/order/phoneYan')}";
                var data={id:id};
                //alert(id);
                $.post(url,data,function(result){
                        console.log(result);
                    if(result.return_code=='00000')
                    {
                        //dialog.success(result.message,success_url);
                        alert('提醒用户成功');
                    }else
                    {
                        //dialog.error(result.message);
                        alert('操作失败');
                    }
                });
            }

            function select_all(that){
                subCheckbox = $(that).siblings("span").find(".checkboxes");
                for (var i=0;i<subCheckbox.length;i++)
                {
                    subCheckbox[i].checked = that.checked;
                }
            }
            function showLogisticsNumberBox(that,id){
                $("#arr_prodcuts").val('');
                var arr_products='';
                subCheckbox = $(that).parents('td').prev().find(".checkboxes");
                for (var i=0;i<subCheckbox.length;i++)
                {
                    if(subCheckbox.eq(i).is(":checked"))
                    {
                        //alert(subCheckbox.eq(i).attr('_id'));
                       var num= subCheckbox.eq(i).attr('_id')
                        arr_products = arr_products+','+num;
                    }
                }
                if(arr_products=='')
                {
                    alert('请选择产品');

                }else {
                    $("#arr_prodcuts").val(arr_products);
                    $("#order_id").val(id);
                    $(that).next(".logistics_number_box").css("display", "block")
                }
            }
            function hideLogisticsNumberBox(that){

                var sps_id=$("#arr_prodcuts").val();
                var id=$("#order_id").val();
                var value=$(that).prev().val();
                var data={id:id,sps_id:sps_id,value:value};
                var success_url="{:url('admin/order/index')}";
                var url="{:url('admin/order/upodate_log')}";
                $.post(url,data,function(result){
                    if(result.status=='4')
                    {
                        dialog.success(result.message,success_url);
                    }else
                    {
                        dialog.error(result.message);
                    }
                })
                $(that).parents(".logistics_number_box").css("display","none")
            }
        </script>
        {/block}